<?php
    include "ip.php";
    include "useragent.php";
    $ip = "";
    $useragent = "";
    $content = "";
    $ip = $ips[rand(0,(count($ips)-1))];
    $useragent = $useragents[rand(0,(count($useragents)-1))];
    $content = getHtml($_REQUEST["term"],$_REQUEST["retmax"],$ip,$useragent);
    if(!($content!="" && !strpos($content,"The document has moved")))
        @file_put_contents("result.txt",$ip."\r\n",FILE_APPEND);
    echo $content;
    function getHtml($term,$retmax,$ip,$useragent)
    {
        $ch = curl_init();
    //		echo $url."[[[[[".urldecode($url)."]]]]]]]".str_replace('\"','"',urldecode($url));
    //		$urls = str_replace(" ","%20",str_replace('\"','"',urldecode($url)));
        $urls = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&usehistory=y&retstart=0&term=".urlencode($term)."&retmax=".$retmax;
        curl_setopt($ch, CURLOPT_URL, $urls);
        curl_setopt($ch, CURLOPT_REFERER ,$urls);
        curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
        curl_setopt($ch, CURLOPT_INTERFACE, $ip);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        if ($_SERVER['REQUEST_METHOD']=='POST')
        {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
        }
        $content = curl_exec($ch);
        //print_r(curl_error($ch));
        curl_close($ch);
        return $content;
    }
?>

